package com.game.ui.progress
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.text.TextField;
	
	/**
	 * 加载进度条 
	 * @author xyj.2013/06/23
	 */
	public class ProgressBar extends Sprite
	{
		private var _skin : MovieClip;
		private var _mcMask : MovieClip;
		private var _txtProgress : TextField;
		private var _loaderInfo : String = "游戏资源加载中";
		
		public function ProgressBar(skin:MovieClip = null)
		{
			if(skin != null)
				_skin = skin;
			init();
		}
		
		protected function init():void
		{
			if(_skin == null)
			{
				_skin = new UiPorgressBar() as MovieClip;
			}
			addChild(_skin);
			
			_mcMask = _skin["maskUi"] as MovieClip;
			_txtProgress = _skin["txtProgress"] as TextField;
		}
		
		public function reset():void
		{
			_mcMask.scaleX = 0;
			_txtProgress.text = "";
		}
		
		public function setPercent(bytesLoaded:Number,bytesTotal:Number):void
		{
			var progress:Number = bytesLoaded/bytesTotal;
			_mcMask.scaleX = progress;
			var count:int = progress*100;
			_txtProgress.htmlText = " 资源加载  "+count + "%";
		}

		public function setLoaderInfo(value:String):void
		{
			_loaderInfo = value;
		}
	}
}